Compare Documents
Visually compare the differences between 2 files.
If you want to visually compare the differences between 2 files, TFTPDF can achieve this by comparing 2 files and generating a new document with the differences.
TFTPDF using pixel-by-pixel comparison in wich an output image will be generated from the differences.
Functions
compare
Add a JSON annotation on the PDF. The command parse the Json with the className and draw the annotation on the correct page.
| Param | Type | Description |
|---|---|---|
| url1 | string | The base document |
| url2 | string | The second document to compare with base |
| quality | string | The quality of the comparison |
| commonColor | string | The desired color to highlight the comparison |
Available quality options:
- low: 65% quality
- medium: 85% quality
- high: 125% quality
Example
TFTPDFGadget.callCommand({
name: 'compare',
args: {
url1: 'https://mediaserver.com/yourfile.pdf',
url2: 'https://mediaserver.com/yourfile.pdf',
quality: 'medium',
commonColor: 'green',
},
callback: myfunc,
});
Avoid CORS error
Please see this guide to setup your application in order to avoid CORS error.
compareWith
Compare the current pdf with another one.
| Param | Type | Description |
|---|---|---|
| url | string | The document you want to compare with |
| quality | string | The quality of the comparison |
| commonColor | string | The desired color to highlight the comparison |
Available quality options:
- low: 65% quality
- medium: 85% quality
- high: 125% quality
Example
TFTPDFGadget.callCommand({
name: 'compareWith',
args: {
url: 'https://mediaserver.com/yourfile.pdf',
quality: 'medium',
commonColor: 'green',
},
callback: myfunc,
});
Avoid CORS error
Please see this guide to setup your application in order to avoid CORS error.
resetCompare
Reset the actual comparison process and reset the viewer.
Example
TFTPDFGadget.callCommand({
name: 'resetCompare',
callback: myfunc,
});